added SSCLI 1.0
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / CSWebBrowserAutomation / HtmlCheckBox.cs
blob8238fa32a2cd93cfbad923f8806dd4c2956636b9
1 /****************************** Module Header ******************************\
2 * Module Name: HtmlCheckBox.cs
3 * Project: CSWebBrowserAutomation
4 * Copyright (c) Microsoft Corporation.
5 *
6 * This class HtmlCheckBox represents an HtmlElement with the tag "input" and its
7 * type is "checkbox".
8 *
9 * This source is subject to the Microsoft Public License.
10 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11 * All other rights reserved.
13 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
14 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
16 \***************************************************************************/
18 using System.Windows.Forms;
19 using System.Security.Permissions;
21 namespace CSWebBrowserAutomation
23 public class HtmlCheckBox : HtmlInputElement
25 public bool Checked { get; set; }
27 /// <summary>
28 /// This parameterless constructor is used in deserialization.
29 /// </summary>
30 public HtmlCheckBox() { }
32 /// <summary>
33 /// Initialize an instance of HtmlCheckBox. This constructor is used by
34 /// HtmlInputElementFactory.
35 /// </summary>
36 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
37 public HtmlCheckBox(HtmlElement element)
38 : base(element.Id)
41 // The checkbox is checked if it has the attribute "checked".
42 string chekced = element.GetAttribute("checked");
43 Checked = !string.IsNullOrEmpty(chekced);
46 /// <summary>
47 /// Set the value of the HtmlElement.
48 /// </summary>
49 [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
50 public override void SetValue(HtmlElement element)
52 // The checkbox is checked if it has the attribute "checked".
53 if (Checked)
55 element.SetAttribute("checked", "checked");
57 else
59 element.SetAttribute("checked", null);